package com.gupaoedu.spring.pattern.proxy.jdk;

import com.gupaoedu.spring.pattern.proxy.staticed.Person;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

public class JDK58 implements InvocationHandler{


    private Person target;


    public Object getInstance (Person target) throws Exception {


        this.target = target;

        Class<?> claszz = target.getClass();

        //  用来生成一个新的对象（由字节码重组来实现）
        Object object =  Proxy.newProxyInstance(claszz.getClassLoader(),claszz.getInterfaces(),this);
        return  object;

    }







    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {

        System.out.println("我是58：我要给你找工作，现在已经拿到你的简历");
        System.out.println("开始投递");

        method.invoke(this.target,args);

        System.out.println("安排面试");

        return null;
    }
}
